<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePortalDocumentTable extends Migration
{
    /**
     * 基础文档
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('portal_document', function (Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('site_id', false, true)->default(0)->comment('站点编号 默认 0:单站点;');
            $table->integer('pid', false, true)->default(0)->comment('上级文档编号');
            $table->string('title')->nullable()->comment('文档标题');
            $table->string('description')->nullable()->comment('简介');
            $table->string('color')->nullable()->comment('标题颜色值');
            $table->integer('create_uid', false, true)->default(0)->comment('发布者 0:后台用户发布');
            $table->string('create_name', 50)->nullable()->comment('后台发布用户名称');
            $table->tinyInteger('category_id', false, true)->default(0)->comment('栏目编号');
            $table->char('document_type', 20)->nullable()->comment('文档类型 多个值用逗号隔开! 默认值： news:资讯; photo:图集; page:单网页模型');
            $table->integer('cover_id', false, true)->default(0)->comment('封面图片编号');
            $table->string('cover')->nullable()->comment('封面图片地址');
            $table->smallInteger('source_id', false, true)->default(0)->comment('来源编号');
            $table->integer('click', false, true)->default(0)->comment('点击量');
            $table->integer('support', false, true)->default(0)->comment('支持数');
            $table->integer('comment', false, true)->default(0)->comment('评论数');
            $table->integer('collect', false, true)->default(0)->comment('搜藏数');
            $table->mediumInteger('sort', false, true)->default(0)->comment('排序');
            $table->tinyInteger('status', false, false)->default(0)->comment('文档状态 默认 0; -1:前台下架; 99:发布; 0:待审核; 1:1级审核通过; 2:2级审核通过;');
            $table->tinyInteger('is_audit', false, false)->default(0)->comment('是否需要审核 0:不需要审核; 1:需要1级审核; 2:需要2级审核;');
            $table->dateTime('fixed_release_time')->nullable()->comment('定时发布时间');
            $table->text('more')->nullable()->comment('扩展字段');
            $table->char('ip', 15)->nullable()->comment('ip地址');

            $table->index(['site_id', 'category_id', 'create_uid', 'ip']);
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('portal_document');
    }
}
